package com.sharing.controller;

import com.sharing.common.Page;
import com.sharing.common.Result;
import com.sharing.domain.ProductionLike;
import com.sharing.domain.User;
import com.sharing.domain.UserLike;
import com.sharing.service.ProductionLikeService;
import com.sharing.service.UserLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MingTian
 * @version 1.0
 * @description TODO
 * @date 2023/4/3 21:11
 */
@RestController
@RequestMapping("/productionlike")
public class ProductionLikeController {
    @Autowired
    private ProductionLikeService productionLikeService;

    /**
     * 根据作品id查询点赞的用户信息(分页)
     * @param productionId
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/productionid")
    public Result<Page<User>> selectLikeUsersByProductionId(Integer productionId, Integer page, Integer size) {
        return productionLikeService.selectLikeUsersByProductionId(productionId, page, size);
    }

    /**
     * 新增作品点赞
     * @param productionLike
     * @return
     */
    @PostMapping
    public Result<ProductionLike> insertProductionLike(@RequestBody ProductionLike productionLike) {
        return productionLikeService.insertProductionLike(productionLike);
    }

    /**
     * 删除作品点赞
     * @param id
     * @return
     */
    @DeleteMapping
    public Result<Integer> deleteProductionLikeById(Integer id) {
        return productionLikeService.deleteProductionLikeById(id);
    }

}
